		<div class="breadcrumb clearfix">
			<div class="title k1">Quản lý bài viết</div>
			<div class="addLink">
				<span class="action"><a class="save" href="#">Sắp xếp</a></span>
				<span class="action"><a class="add" href="<?php echo $this->baseUrl();?>/admin/topic/create/">Thêm mới</a></span>
			</div>
		</div>
		<div class="table_member">
			<form action="<?php echo $this->baseUrl();?>/admin/topic/order" method="POST" id="frm">
			<table cellspacing="0" cellpadding="0" border="0" width="100%">
					<tbody>
						<tr>
							<td valign="middle" colspan="8" class="firstRow">
								<ul class="func">
									<li class="link"><a title="Chức năng" href="#"><span>Chức năng</span></a></li>
								</ul>
							</td>
						</tr>
						<tr>
							<td width="3%" class="secondRow center">STT</td>
							<td width="1%" class="secondRow"><input id="checkAll" type="checkbox" value="" name="upid"></td>
							<td width="20%" class="secondRow">Tên bài</td>
							<td width="25%" class="secondRow">Danh mục</td>
							<td width="15%" class="secondRow">Ngày tạo</td>
							<td width="15%" class="secondRow">Ngày cập nhật</td>
							<td width="10%" class="secondRow center">Sắp xếp</td>
							<td width="12%" class="secondRow">Chức năng</td>
						</tr>
						<?php $i = $this->page*$this->limit;?>
						<?php if(count($this->topics)):?>
						<?php foreach($this->topics as $item):?>
						<?php 
							if($item['active'] == 1) {
								$approveImg = "icon_approve.jpg";
								$approveMsg = "Trạng thái hiện";
							} else {
								$approveImg = "icon_approve_off.jpg";
								$approveMsg = "Trạng thái ẩn";
							}
						?>
						<tr>
							<td class="ctn center"><?php echo $i++;?></td>
							<td align="center" class="ctn"><input type="checkbox" value="<?php echo $item['topic_id'];?>" name="upid"></td>
							<td class="ctn"><a href="<?php echo $this->baseUrl();?>/admin/topic/edit/topic_id/<?php echo $item['topic_id'];?>"><strong><?php echo $item['topic_name']?></strong></a></td>
							<td class="ctn"><a href="<?php echo $this->baseUrl();?>/admin/categorytopic/"><strong><?php echo $item['category_name']?></strong></a></td>
							<td class="ctn"><a><?php echo date('d/m/Y', $item['created']);?></a></td>
							<td class="ctn"><a><?php echo date('d/m/Y', $item['updated']);?></a></td>
							<td class="ctn center"><input type="text" name="order_<?php echo $item['user_id'];?>" value="<?php echo $item['ordering'];?>" size="5" /></td>
							<td class="ctn">
								<a class="action" title="Sửa" href="<?php echo $this->baseUrl();?>/admin/topic/edit/topic_id/<?php echo $item['topic_id'];?>"><img src="<?php echo $this->baseUrl();?>/admin/images/icon_edit.jpg" alt="Sửa" /></a>
								<a class="action approve" rel="<?php echo $item['topic_id'];?>" href="#" id="<?php echo $item['active'];?>"><img src="<?php echo $this->baseUrl();?>/admin/images/<?php echo $approveImg;?>" alt="<?php echo $approveMsg;?>" title="<?php echo $approveMsg;?>" /></a>
								<a class="action delete" rel="<?php echo $item['topic_id'];?>" title="Xóa" href="#"><img src="<?php echo $this->baseUrl();?>/admin/images/icon_del.jpg" alt="Xóa" /></a>
							</td>
						</tr>
						<?php endforeach; ?>
						<?php else: ?>
						<tr>
							<td valign="middle" colspan="8" class="ctn center">
								Không có mẫu tin nào !
							</td>
						</tr>
						<?php endif;?>
						<tr>
							<td valign="middle" colspan="8" class="firstRow">
								<ul class="func">
									<li class="link"><a title="Tạo bài mới" href="#"><span>Tạo bài mới</span></a></li>
								</ul>
							</td>
						</tr>
					</tbody>
				</table>
				</form>
		</div>		
		<?php echo $this->paging($this->baseUrl(), 'admin', 'topic', 'list', null, $this->amount, $this->page, $this->limit);?>
<script type="text/javascript">
    $(function(){ 
    	$('#checkAll').click(function () {
			$('.table_member').find(':checkbox').attr('checked', this.checked);
		});
    });
    $(document).ready(function(){
    	$("a.delete").click(function(){
            var topic_id = $(this).attr('rel');
            $(this).myBoxy (Boxy,{
                type: 'confirm',
                message: 'Bạn muốn xóa bài này không?',
                topic_id : topic_id,
                callback: function(){
                    var boxy = Boxy.get(this);
                    if (!boxy)
                    {
                        return;
                    }

                    var options = boxy.options;
                    boxy.hideAndUnload();

                    $.getJSON(baseurl+'/topic/delete', {
                        topic_id: options.topic_id
                    }, function(data){
                        if (data.status == 1)
                        {
                            $(this).myBoxy (Boxy,{
                                type: 'success',
                                message: 'Xóa bài viết thành công!'
                            });
                            setTimeout('location.reload()', 250);
                        }
                        else
                        {
                            $(this).myBoxy (Boxy,{
                                type: 'alert',
                                message: 'Có lỗi khi xóa!'
                            });
                        }
                    });
                }
            });

        });
    });
</script>